package com.wang.designpattern.factory.simplefactory.pizzastore.store;

import com.wang.designpattern.factory.simplefactory.pizzastore.pizza.*;

/**
 * 简单工厂类
 */
public class SimpleFactory {
    /**
     * 使用简单工厂模式订购披萨
     * @param orderType
     * @return
     */
    public Pizza orderPizza(String orderType) {
        System.out.println("使用简单工厂模式");
        Pizza pizza = null;
        if (orderType.equals("cheese")) {
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        } else if (orderType.equals("greek")) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if (orderType.equals("pepper")) {
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        } else if (orderType.equals("liulian")) {
            pizza = new LiulianPizza();
            pizza.setName("榴莲披萨");
        }
        return pizza;
    }
}
